import Vue from "vue";
import VueRouter from "vue-router";
// import Home from "../views/Home.vue";
import login from "@/views/login";
import reg from "@/views/reg";
import home from "@/views/home";
import appUsers from "@/views/appUsers";
import appGoods from "@/views/appGoods";
import appOrders from "@/views/appOrders";
// import helloWord from "@/components/HelloWord.vue";

const originalPush= VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter);

const routes = [
  {
    path:"/",
    redirect: "/home"
  },
  // {
  //   path:"/hello",
  //   name:"hello",
  //   component:helloWord
  // },
  {
    path: "/login",
    name: "login",
    component: login
  },
  {
    path:"/reg",
    name:"reg",
    component:reg
  },
  {
    path:"/home",
    name:"home",
    component:home,
    children:[
      // {
      //   path:"/",
      //   redirect: "users"
      // },
      {
        path:"goods",
        name:"goods",
        component:appGoods
      },
      {
        path:"users",
        name:"users",
        component:appUsers
      },
      {
        path:"orders",
        name:"orders",
        component:appOrders
      }
    ]
  }
];

const router = new VueRouter({
  routes
});

export default router;
